package com.hanmanyi.scanning.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hanmanyi.scanning.util.FileUtil;
import com.hanmanyi.scanning.util.HttpCode;
import com.hanmanyi.scanning.util.Rest;

/**
 * 控制器
 *
 * @author kanen
 * @create 2018-12-07 11:07
 */
@Controller
public class ScannerController{

    
    @Value("${file.save.path}")
    private String savePath;

    @RequestMapping("/index")
    public String index()
    {
        return "index";
    }

    @ResponseBody
    @RequestMapping("/savePicture")
    public Rest savePicture(String imgData) throws Exception{
    	imgData = imgData.replace("data:image/jpeg;base64,", "");
        //保存图片到指定路径
    	FileUtil.BASE64CodeToBeImage(imgData, savePath,"jpg");
    	//保存成功
    	return Rest.newBuilder().code(HttpCode.OK).build();
    }
}
